package com.galaxy.payment.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web MVC配置
 */
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final WxAuthInterceptor wxAuthInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册微信小程序认证拦截器，拦截/api/payment/wx/**路径
        registry.addInterceptor(wxAuthInterceptor)
            .addPathPatterns("/api/payment/wx/**")
            .excludePathPatterns("/api/payment/wx/callback"); // 支付回调不需要认证
    }
} 